package org.ycx.upms.dao.auto;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.ycx.upms.dao.model.SecSystem;
import org.ycx.upms.dao.model.SecSystemExample;

import java.util.List;

public interface SecSystemMapper {
    @SelectProvider(type=SecSystemSqlProvider.class, method="countByExample")
    long countByExample(SecSystemExample example);

    @DeleteProvider(type=SecSystemSqlProvider.class, method="deleteByExample")
    int deleteByExample(SecSystemExample example);

    @Delete({
        "delete from sec_system",
        "where SID = #{sid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer sid);

    @Insert({
        "insert into sec_system (NAME, SYSTEM_DESC, ",
        "ICON, THEME, BASEURI, ",
        "STATE, SYS_KEY, BANNER, ",
        "CREATE_TS, CREATE_UID, ",
        "UPDATE_TS, UPDATE_UID)",
        "values (#{name,jdbcType=VARCHAR}, #{systemDesc,jdbcType=VARCHAR}, ",
        "#{icon,jdbcType=VARCHAR}, #{theme,jdbcType=VARCHAR}, #{baseuri,jdbcType=VARCHAR}, ",
        "#{state,jdbcType=VARCHAR}, #{sysKey,jdbcType=VARCHAR}, #{banner,jdbcType=VARCHAR}, ",
        "#{createTs,jdbcType=DATE}, #{createUid,jdbcType=INTEGER}, ",
        "#{updateTs,jdbcType=DATE}, #{updateUid,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="sid", before=false, resultType=Integer.class)
    int insert(SecSystem record);

    @InsertProvider(type=SecSystemSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="sid", before=false, resultType=Integer.class)
    int insertSelective(SecSystem record);

    @SelectProvider(type=SecSystemSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="SID", property="sid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="NAME", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="SYSTEM_DESC", property="systemDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="ICON", property="icon", jdbcType=JdbcType.VARCHAR),
        @Result(column="THEME", property="theme", jdbcType=JdbcType.VARCHAR),
        @Result(column="BASEURI", property="baseuri", jdbcType=JdbcType.VARCHAR),
        @Result(column="STATE", property="state", jdbcType=JdbcType.VARCHAR),
        @Result(column="SYS_KEY", property="sysKey", jdbcType=JdbcType.VARCHAR),
        @Result(column="BANNER", property="banner", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER)
    })
    List<SecSystem> selectByExample(SecSystemExample example);

    @Select({
        "select",
        "SID, NAME, SYSTEM_DESC, ICON, THEME, BASEURI, STATE, SYS_KEY, BANNER, CREATE_TS, ",
        "CREATE_UID, UPDATE_TS, UPDATE_UID",
        "from sec_system",
        "where SID = #{sid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="SID", property="sid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="NAME", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="SYSTEM_DESC", property="systemDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="ICON", property="icon", jdbcType=JdbcType.VARCHAR),
        @Result(column="THEME", property="theme", jdbcType=JdbcType.VARCHAR),
        @Result(column="BASEURI", property="baseuri", jdbcType=JdbcType.VARCHAR),
        @Result(column="STATE", property="state", jdbcType=JdbcType.VARCHAR),
        @Result(column="SYS_KEY", property="sysKey", jdbcType=JdbcType.VARCHAR),
        @Result(column="BANNER", property="banner", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER)
    })
    SecSystem selectByPrimaryKey(Integer sid);

    @UpdateProvider(type=SecSystemSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") SecSystem record, @Param("example") SecSystemExample example);

    @UpdateProvider(type=SecSystemSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") SecSystem record, @Param("example") SecSystemExample example);

    @UpdateProvider(type=SecSystemSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(SecSystem record);

    @Update({
        "update sec_system",
        "set NAME = #{name,jdbcType=VARCHAR},",
          "SYSTEM_DESC = #{systemDesc,jdbcType=VARCHAR},",
          "ICON = #{icon,jdbcType=VARCHAR},",
          "THEME = #{theme,jdbcType=VARCHAR},",
          "BASEURI = #{baseuri,jdbcType=VARCHAR},",
          "STATE = #{state,jdbcType=VARCHAR},",
          "SYS_KEY = #{sysKey,jdbcType=VARCHAR},",
          "BANNER = #{banner,jdbcType=VARCHAR},",
          "CREATE_TS = #{createTs,jdbcType=DATE},",
          "CREATE_UID = #{createUid,jdbcType=INTEGER},",
          "UPDATE_TS = #{updateTs,jdbcType=DATE},",
          "UPDATE_UID = #{updateUid,jdbcType=INTEGER}",
        "where SID = #{sid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(SecSystem record);
}